function replaceCustomWorkspaceIcon() {
    const customIconPath = "/assets/nepal_compliance/icon/nepal-compliance.svg";
    const targetHref = `#icon-${customIconPath}`;
  
    document.querySelectorAll('svg.icon use').forEach((useTag) => {
      const href = useTag.getAttribute('href');
      if (href === targetHref) {
        const svg = useTag.closest('svg');
        const container = svg?.closest('.sidebar-item-icon');
        if (container && !container.querySelector('img')) {
          container.innerHTML = `<svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
        <g clip-path="url(#clip0_3491_58252)">
        <path d="M6.14876 9.30876H11.2189V11.291H10.9331C10.9106 11.291 10.8881 11.291 10.8661 11.291C10.4713 11.2943 10.0765 11.2968 9.68177 11.2997C8.71584 11.3064 7.71704 11.3134 6.73489 11.3272C6.52232 11.3301 6.36424 11.3995 6.26607 11.5335C6.15375 11.6862 6.12837 11.9179 6.19826 12.1525C6.4387 12.9616 6.98323 13.5078 7.77278 13.732C7.85349 13.7549 7.93294 13.7665 8.00948 13.7665C8.31773 13.7665 8.52906 13.5851 8.60477 13.2561C8.63763 13.1126 8.65468 12.9649 8.67257 12.8089C8.68089 12.7365 8.68921 12.6646 8.69919 12.5926L8.71916 12.4491H11.2259V15.6281H12.7509V9.30211H13.8321V8.16645H6.14876V9.30876Z" fill="currentColor"/>
        <path d="M8.95193 5.59094C9.10751 5.55517 9.25435 5.52189 9.40952 5.51149C9.46859 5.50775 9.52267 5.50567 9.5755 5.50567C9.96903 5.50567 10.2602 5.61798 10.4923 5.85926C10.7444 6.12133 10.8771 6.43457 11.0127 6.78692L11.0144 6.79149C11.0984 7.02944 11.1829 7.26115 11.2661 7.4862H12.507C12.4779 7.39593 12.4492 7.30524 12.4205 7.21455C12.3256 6.91421 12.2274 6.60347 12.111 6.30894C11.8489 5.64585 11.5598 5.19825 11.1746 4.85797C10.8276 4.55138 10.3971 4.38873 9.85837 4.36128C9.79015 4.35795 9.72068 4.35587 9.65287 4.35587C9.46651 4.35587 9.28389 4.36918 9.11042 4.39497C8.94236 4.41993 8.77555 4.46735 8.59917 4.51727C8.57546 4.52393 8.55091 4.531 8.52679 4.53766L8.88495 5.60634C8.90742 5.60134 8.92988 5.59594 8.95193 5.59094Z" fill="currentColor"/>
        <path d="M16.8551 0H3.14489C1.41062 0 0 1.41062 0 3.14489V16.8551C0 18.5894 1.41062 20 3.14489 20H16.8551C18.5894 20 20 18.5894 20 16.8551V3.14489C20 1.41062 18.589 0 16.8551 0ZM19.168 16.8551C19.168 18.1305 18.1305 19.168 16.8551 19.168H3.14489C1.86946 19.168 0.831981 18.1305 0.831981 16.8551V3.14489C0.831981 1.86946 1.86946 0.831981 3.14489 0.831981H16.8551C18.1305 0.831981 19.168 1.86946 19.168 3.14489V16.8551Z" fill="currentColor"/>
        </g>
        <defs>
        <clipPath id="clip0_3491_58252">
        <rect width="20" height="20" fill="white"/>
        </clipPath>
        </defs>
        </svg>`;
        }
      }
    });
  }
  
  frappe.after_ajax(() => {
    setTimeout(replaceCustomWorkspaceIcon, 1000);
  });
  
  frappe.router.on('change', () => {
    setTimeout(replaceCustomWorkspaceIcon, 1000);
  }); 
